home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr2.arc / MEMCCPY.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  930b  |  29 lines

  1. /*  File   : memccpy.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 May 1984
  4.     Defines: memccpy()
  5.  
  6.     memccpy(dst, src, chr, len)
  7.     copies bytes from src to dst until either len bytes have been moved
  8.     or a byte equal to chr has been moved.  In the former case it gives
  9.     NullS as the value, in the latter a pointer to just after the place
  10.     where "chr" was moved to in dst.  Note that copying stops after the
  11.     first instance of "chr", and that remaining characters in "dst" are
  12.     not changed in any way, no NUL being inserted or anything.
  13.  
  14.     See the "Character Comparison" section in the READ-ME file.
  15. */
  16.  
  17. #include "strings.h"
  18.  
  19. char *memccpy(dst, src, chr, len)
  20.     register char *dst, *src;
  21.     register int chr;          /* should be char */
  22.     register int len;
  23.     {
  24.        while (--len >= 0)
  25.            if ((*dst++ = *src++) == chr) return dst;
  26.        return NullS;
  27.     }
  28.  
  29.